package top.saybook.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import top.saybook.pojo.Book;
import top.saybook.pojo.Chapter;
import top.saybook.service.BookService;

import java.util.List;
import java.util.Map;

@RestController
@RequestMapping("/book")
@CrossOrigin
public class BookController {

    @Autowired
    private BookService bookService;

    @RequestMapping("/selectAll")
    public List<Book> selectAll(String bookName){
        return bookService.selectAll(bookName);
    }

    @RequestMapping("/findChapterList/{bookId}")
    public Map findChapterList(@PathVariable("bookId") Integer bookId){
        return bookService.findChapterList(bookId);
    }

    @RequestMapping("/findByChapterContent/{chapterId}")
    public Map findByChapterContent(@PathVariable("chapterId") Integer chapterId){
        return  bookService.findByChapterContent(chapterId);
    }
}
